package com.ujs.edu.demo.dao;

import com.ujs.edu.demo.dataobject.BcCart;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface BcCartMapper {
    @Delete({
            "delete from bc_cart",
            "where cart_id = #{cartId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer cartId);

    @Insert({
            "insert into bc_cart (cart_id, name, ",
            "cartlogo, createtime, ",
            "modifytime)",
            "values (#{cartId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
            "#{cartlogo,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP}, ",
            "#{modifytime,jdbcType=TIMESTAMP})"
    })
    int insert(BcCart record);

    @Select({
            "select",
            "cart_id, name, cartlogo, createtime, modifytime",
            "from bc_cart",
            "where cart_id = #{cartId,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="cart_id", property="cartId", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="cartlogo", property="cartlogo", jdbcType=JdbcType.VARCHAR),
            @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modifytime", property="modifytime", jdbcType=JdbcType.TIMESTAMP)
    })
    BcCart selectByPrimaryKey(Integer cartId);

    @Select({
            "select",
            "cart_id, name, cartlogo, createtime, modifytime",
            "from bc_cart"
    })
    @Results({
            @Result(column="cart_id", property="cartId", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="cartlogo", property="cartlogo", jdbcType=JdbcType.VARCHAR),
            @Result(column="createtime", property="createtime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="modifytime", property="modifytime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<BcCart> selectAll();

    @Update({
            "update bc_cart",
            "set name = #{name,jdbcType=VARCHAR},",
            "cartlogo = #{cartlogo,jdbcType=VARCHAR},",
            "createtime = #{createtime,jdbcType=TIMESTAMP},",
            "modifytime = #{modifytime,jdbcType=TIMESTAMP}",
            "where cart_id = #{cartId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BcCart record);
}